#include "ZigbeeGWInfraredCmd.h"

ZigbeeGWInfraredCmd::ZigbeeGWInfraredCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::ZigbeeGWProtocol;
    this->m_functionCode = FunctionCode;
}

Package ZigbeeGWInfraredCmd::toPackage()
{
    Package package;
    package.setFunction(FunctionCode);
    return package;
}

void ZigbeeGWInfraredCmd::unPackage(Package package)
{
    qDebug()<<"unpackage zigbeeGW SICmd";
    qDebug()<<package.body().toHex().data();
    QByteArray body = package.body();
    quint16 length=body.mid(4,1).toHex().toInt(0,16);
//    m_nwk=body.mid(2,2);
    m_nwk=body.mid(2,1);
    m_nwk.append(body.mid(3,1));
    m_Data=body.mid(5,length);
    qDebug()<<"length="<<QString::number(length);
    qDebug()<<"m_nwk="<<m_nwk.toHex().toInt(0,16);
    qDebug()<<"m_data="<<m_Data.toHex().toInt(0,16);
}
QByteArray ZigbeeGWInfraredCmd::Nwk()
{
    return m_nwk;
}
QByteArray ZigbeeGWInfraredCmd::Data()
{
    return m_Data;
}
